<template>
	<view>
		<view class="search-nav">
			<view><uni-search-bar placeholder="搜索内容" radius="8" bgColor="#FFFFFF" @confirm="onSearch" @clear="onCancel" cancelButton="none" @input="onInput" /></view>
			<view class="p10-0">
				<text class="searchBtn" @click="onSearchBtn">搜索</text>
			</view>
		</view>
		<uni-list :border="true">
			<uni-list-item v-for="item in dataInfo" :key='item.id' clickable @click="onLink('info/index',item.id)" :title="item.title" :note="'阅读：' + item.click + '　点赞：' + item.likes_count" showArrow :thumb="item.img" thumb-size="lg"/>
		</uni-list>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				form:{page:1,type:0},
				dataInfo:[],
			}
		},
		onLoad(options){
			this.form.type = options.id
			this.onGetInfo()
		},
		methods: {
			onGetInfo(){
				let _this = this
				this.$request_api('applet_api/node','POST',this.form).then(res => {
					_this.form.page++
					if(_this.dataInfo.length >= res.total){
						_this.loadData = false
						_this.status = 'no-more'
					}
					_this.dataInfo.push(...res.data) 
				}).catch(err => {
					console.log(err)
				})
			},
			onSearch(e){
				this.form.title = e.value
				this.form.page = 1
				this.dataInfo = []
				this.onGetInfo()
			},
			onInput(e){
				this.form.title = e
			},
			onSearchBtn(){
				this.form.page = 1
				this.dataInfo = []
				this.onGetInfo()
			},
			onCancel(e){
				this.form.title = ''
				this.form.page = 1
				this.dataInfo = []
				this.onGetInfo()
			},
			onLink(url,id){
				uni.navigateTo({
					url: "/pages/node/"+url+"?id="+id
				});
			}
		}
	}
</script>

<style scoped lang="scss">
</style>
